package com.starview.star.compiler.wff;

import com.starview.platform.data.type.Location;
import com.starview.star.compiler.Display;
import com.starview.star.compiler.ast.IAbstract;
import com.starview.star.compiler.util.PrettyPrintDisplay;

@SuppressWarnings("serial")
public class WffLitPtn implements WffOp
{
  private final IAbstract lit;

  public WffLitPtn(IAbstract lit)
  {
    this.lit = lit;
  }

  @Override
  public applyMode apply(IAbstract term, IAbstract env[], Location loc, WffEngine engine)
  {
    if (lit.equals(term))
      return applyMode.validates;
    else
      return applyMode.notValidates;
  }

  @Override
  public void prettyPrint(PrettyPrintDisplay disp)
  {
    Display.display(disp, lit);
  }

  @Override
  public String toString()
  {
    return PrettyPrintDisplay.toString(this);
  }

  @Override
  public long specificity()
  {
    return Complexity.complexity(lit);
  }
}
